" colemak keyboard layout, maybe become history

set easymotion
let mapleader=" "

set keep-english-in-normal
" imap a z
let g:EasyMotion_do_mapping=0
map s <Plug>(easymotion-sn)

nmap ,f <Action>(MaximizeEditorInSplit)
inoremap jj <Esc>

" Error Decription, default key: Ctrl + F1
nnoremap ,r :action RunAnything<cr>
nnoremap ,e :action ShowErrorDescription<cr>
" Next Highlighted Error, default key: Alt + F8
nnoremap <leader>ne :action GotoNextError<cr>
" Previous Highlighted Error, default key: Alt + Shift + F8
nnoremap <leader>pe :action GotoPreviousError<cr>
nnoremap z9 :action Debug<cr>
nnoremap zm :action ToggleLineBreakpoint<cr>
nnoremap zz :action ShowExecutionPoint<cr>
nnoremap ze :action StepOver<cr>
nnoremap zi :action StepInto<cr>
nnoremap zu :action StepOut<cr>
nnoremap <leader>rn :action RenameElement<cr>
vnoremap <leader>sn :action SaveAsTemplate<cr>
" nnoremap <C-o> :action NewFile<cr>
nnoremap <A-n> :action PreviousTab<cr>
nnoremap <A-i> :action NextTab<cr>
nnoremap <A-e> :action GoToLastTab<cr>
nnoremap <A-r> :source ~\AppData\Local\nvim\idea.vim<cr>
nnoremap <leader>rc :source ~\AppData\Local\nvim\idea.vim<cr>
nnoremap <silent> <space>oo :exec '!alacritty.exe -e nvim -c '.line(".").' %'<cr>
noremap <A-k> :action CommentByLineComment<cr>
" nnoremap <A-r> :action IdeaVim.ReloadVimRc.reload<cr>
" nnoremap <Esc> <Esc>:nohl<cr>:action HideActiveWindow<cr>
nnoremap <Esc> <Esc>:nohl<cr>
nnoremap X :action ReopenClosedTab<cr>
nnoremap <A-p> :action PinActiveTabToggle<cr>
nnoremap m :action ToggleBookmark<cr>
nnoremap M :action ShowBookmarks<cr>
nnoremap <Space>pp :action CloseAllUnpinnedEditors<cr>
nnoremap <Space>nn :action Build<cr>
nnoremap <Space>ne :action Run<cr>

set foldlevelstart=99
set shortmess+=c
set updatetime=100
set termencoding=utf-8
set fileencoding=utf-8
set timeoutlen=3000
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set scrolloff=99
set sidescrolloff=6
set tw=0
set indentexpr=
set backspace=indent,eol,start
set foldmethod=marker
set laststatus=2
set shortmess=atl
set formatoptions=tcrqn
set number
" set relativenumber
syntax on
set wrap
set linebreak
set showcmd
set noshowmode
set wildmenu
set hlsearch
set incsearch
set ignorecase
set smartcase
set clipboard+=unnamed,unnamedplus
set clipboard+=unnamedplus
set cursorline
set cmdheight=1
set visualbell
set noerrorbells
set showmatch
set autoindent
set smartindent
set cindent
set hidden

" colemak keyboard setting
noremap h i
noremap H I
noremap n h
noremap N ^
noremap e j
nnoremap E 10j
vnoremap E 3j
noremap I $
noremap i l
noremap u k
nnoremap U 10k
vnoremap U 3k
noremap l u
noremap L <C-r>
noremap k n
noremap K N
noremap ge gj
noremap gu gk
noremap j e
noremap J E
noremap <A-u> <nop>
noremap <A-e> <nop>
noremap <A-I> <C-w><Right>
noremap <A-N> <C-w><Left>
noremap <A-E> <C-w><Down>
noremap <A-U> <C-w><Up>
inoremap <A-i> <Right>
inoremap <A-n> <Left>

" b w 移动一个单词
noremap b B
noremap B b
noremap w W
noremap W w

" noremap  <A-u> {
" noremap  <A-e> }
" noremap ]p p
" noremap p ]p
noremap <LEADER>ay ggyG
noremap <LEADER>ad ggdG
noremap <LEADER>ap ggVGP
noremap <LEADER>qn @n
noremap @ @n
noremap <LEADER>e :e!<CR>
noremap <A-f> /
nnoremap tt :action GotoFile<cr>
nmap <LEADER><LEADER> <Esc>/>++><CR>:nohlsearch<CR>c4i
noremap <LEADER>ll :set cursorcolumn<CR>
" noremap   <A--> <C-o>
nnoremap - <C-o>
" noremap   <A-=> <C-i>
" nnoremap == <C-i>
nnoremap = <C-i>
inoremap <A-o> <nop>
" inoremap <A-e> <nop>
" noremap si :set splitright<CR>:vsplit<CR>
" noremap sn :set nospr<CR>:vsplit<CR>
" noremap se :set splitbelow<CR>:split<CR>
" noremap su :set nosplitbelow<CR>:split<CR>
noremap <LEADER>ta :tabe<CR>

nnoremap <A-q> :q!<CR>
nnoremap <A-w> :w<CR>
noremap ? *
noremap! <A-w> <Esc>:w<CR>
" noremap!   <Esc>
noremap <A-o> o<Esc>O
nnoremap > >>
nnoremap < <<
nnoremap <LEADER>d <C-]>
" fold and unfold {{{
noremap <LEADER>o za

" register yank and paste {{{
noremap <LEADER>pn "np
noremap <LEADER>pe "ep
noremap <LEADER>pi "ip
vnoremap <LEADER>yn "ny
vnoremap <LEADER>ye "ey
vnoremap <LEADER>yi "iy
vnoremap  <Esc>
" }}}

inoremap tna 1
inoremap tnr 2
inoremap tns 3
inoremap tnt 4
inoremap tnd 5
inoremap tnh 6
inoremap tnn 7
inoremap tne 8
inoremap tni 9
inoremap tno 0
inoremap tnA !
inoremap tnR @
inoremap tnS #
inoremap tnT $
inoremap tnD %
inoremap tnH ^
inoremap tnN &
inoremap tnE *
inoremap tnI (
inoremap tnO )
inoremap tn<Enter> \n
inoremap tnl ()<left>
inoremap tnu []<left>
inoremap tny <end><space>{}<left>
inoremap tnY {}<left>
inoremap tn<Enter> \n
imap tn<SPACE> >++>

inoremap <A-l> ()<left>
inoremap <A-u> []<left>
inoremap <A-y> <end>{}<left>
inoremap  <Esc>

inoremap aoa !
inoremap aor @
inoremap aos #
inoremap aot $
inoremap aod %
inoremap aoh ^
inoremap aon &
inoremap aoe *
inoremap aoi (
inoremap aoo )
